<div id="sf_admin_container">

	<div id="sf_admin_content" >

		<form id="frmCommon" method="POST" action="superAdmin" >
			<fieldset>
				<div class="form-row">&nbsp;</div>
				<div class="form-row">
					<input type="hidden" name="action_type" value="get" id="action_type"/>

					<label>Tên lệnh</label>
					<select name="optStatisticType"  id="optStatisticType" style="width: 300px;"  onchange="cboSQLStringOnChange();">

						<?php foreach ( $sqlLists as $sql): ?>
								<?php if ($sql->getId() == $optValue) :?>
									<?php $sqlString = $sql->getSqlString(); ?>
									<option selected="selected" value="<?php echo $sql->getId(); ?>"> <?php echo $sql->getName();?> </option>
								<?php else :?>
									<option value="<?php echo $sql->getId(); ?>"> <?php echo $sql->getName();?> </option>
								<?php endif; ?>
						<?php endforeach; ?>

					</select>
				</div>

				<div class="form-row">
					<label>Mã lệnh</label>
					<div>
						<textarea id="sqlString"   name="sqlString"   style="width:500px; height:150px" ><?php echo $sqlString;?></textarea>
					</div>
				</div>

				<div class="form-row" style="clear:both; margin-left: 122px">
					<?php echo submit_tag('Thực hiện lại', 'style="width:80px"') ?>
					<?php echo submit_tag('Lưu lại', 'style="width:80px" onclick="btnSaveAsSQL_OnClick();"'); ?>
						với tên mới là <input type="text" id="asName" name="asName">
				 		* ( Để trắng nếu muốn giữ nguyên tên )
				</div>

			</fieldset>
		</form>

		<label>Kết quả thực hiện</label>
		<div  id="result_search">
			<?php if ( $permission == false):?>
				Bạn không có quyền thực hiện lệnh này"
			<?php else: ?>
				<?php if ($result): ?>
				  	<strong><?php echo $result->getRecordCount();?> bản ghi</strong>

				  <table class="sf_admin_list"  cellspacing="0" style="width:60%">
				  	<thead></thead>
				  	<tbody>
					<?php  $i = 1; foreach ($result as $row): $odd = fmod(++$i, 2) ?>
						<tr class="sf_admin_row_<?php echo $odd ?>">
							<?php
								$totalCol =  sizeof($row);
								for ( $j =1; $j<= $totalCol; $j ++)
								{
									echo ' <td>'.$result->get($j).' </td>';
								}
							?>
						</tr>

					<?php endforeach; ?>
					</tbody>
					<tfoot></tfoot>
				</table>
				<?php endif; ?>
			<?php endif; ?>

		</div>
	</div>
</div>

<script language="Javascript">
function cboSQLStringOnChange(){
	frm = document.getElementById('frmCommon');
	frm.submit();
}

function btnSaveAsSQL_OnClick(){
	actionType = document.getElementById('action_type');
	actionType.value = "update";
}


</script>
	